#include <cstdio>

double max( double x, double y ) { return ( x > y )? x: y; }
double min( double x, double y ) { return ( x < y )? x: y; }

struct Point { double x, y; };

struct Segment { Point p1, p2; };

double multi( Point p1, Point p2, Point p0 )
{
    return ( p1.x - p0.x ) * ( p2.y - p0.y ) - ( p2.x - p0.x ) * ( p1.y - p0.y );
}

Segment e[ 101 ];
int n;

void init( )
{
    int i;
    for ( i = 0; i < n; i++ )
        scanf("%lf%lf%lf%lf", &e[ i ].p1.x, &e[ i ].p1.y, &e[ i ].p2.x, &e[ i ].p2.y);
}

bool check( Point s1, Point e1, Point s2, Point e2 )
{
    if (
    max( s1.x, e1.x ) >= min( s2.x, e2.x ) &&
    max( s2.x, e2.x ) >= min( s1.x, e1.x ) &&
    max( s1.y, e1.y ) >= min( s2.y, e2.y ) &&
    max( s2.y, e2.y ) >= min( s1.y, e1.y ) &&
    multi( s2, e1, s1 ) * multi( e1, e2, s1 ) >= 0 &&
    multi( s1, e2, s2 ) * multi( e2, e1, s2 ) >= 0
    )
        return true;
    return false;
}

void work( )
{
    int count = 0, i, j;
    for ( i = 0; i < n; i++ )
        for ( j = i + 1; j < n; j++ )
            if ( check( e[ i ].p1, e[ i ].p2, e[ j ].p1, e[ j ].p2 ) )
                count++;
    printf("%d\n", count);
}

int main( )
{
    while ( scanf("%d", &n) && n )
    {
        init( );
        work( );
    }
    return 0;
}
